<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>商城购物车结算页面</title>
    <link type="text/css" rel="stylesheet" href="index.css">
</head>
<body>
<div id="app">
    <div v-if="books.length >0">
        <table>
            <caption>书籍购物车结算</caption>
            <thead>
            <tr>
                <th>编号</th>
                <th>书籍名称</th>
                <th>出版日期</th>
                <th>单价</th>
                <th>购买数量</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
            <tr v-for="(item, index) in books">
                <td>{{ item.id }}</td>
                <td>{{ item.name }}</td>
                <td>{{ item.date }}</td>
                <td>{{ item.price }}</td>
                <td>
                    <button v-on:click="item.count --" v-bind:disabled="item.count <= 1">-</button>
                    {{ item.count }}
                    <button v-on:click="item.count ++">+</button>
                </td>
                <td>
                    <button v-on:click="books.splice(index,1)">删除</button>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <td colspan="5" style="text-align: right">结算</td>
            <td>{{ total }}</td>
            </tfoot>
        </table>
    </div>
    <div v-else>
        <h2>购物车为空！</h2>
    </div>
</div>

<script type="module" src="index.js"></script>
</body>
</html>